//
//  UIColor+WZColor.m
//  Meniny
//
//  Created by Meniny on 16/6/24.
//  Copyright © 2016年 Meniny. All rights reserved.
//

#import "UIColor+WZColor.h"

@implementation UIColor (WZColor)
//+ (UIColor *)deepCarrotOrangeColor {
//    return [UIColor colorWithRed:0.90 green:0.38 blue:0.18 alpha:1.00];
//}
//
//+ (UIColor *)piazzColor {
//    return [UIColor colorWithRed:0.93 green:0.46 blue:0.22 alpha:1.00];
//}

+ (UIColor *)appColor {
//  #55E6BB  return [UIColor colorWithRed:0.12 green:0.12 blue:0.12 alpha:1.00];
    return [UIColor colorWithHexString:@"#04DAA6"];
}

+(UIColor *)linkColor{
    return [UIColor colorWithHexString:@"#44DFAD"];
}

+(UIColor *)titleColor{
    return [UIColor blackColor];
}

+ (UIColor *)appLightGrayColor{
    return [UIColor colorWithHexString:@"E5E5E5"];
}

+ (UIColor *)appLightLightGrayColor{
    return [UIColor colorWithHexString:@"E1E1E1"];
}

//app背景颜色
+ (UIColor *)appBackgroundColor{
    return [UIColor colorWithHexString:@"#FCFFFF"];
}
+ (UIColor *)concreteColor {
    return [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1];
}

+ (UIColor *)appIconColor {
    return [UIColor colorWithRed:0.23 green:0.87 blue:0.85 alpha:1.00];
}

+ (UIColor *)appLightColor{
    return [UIColor colorWithRed:230/255 green:230/255 blue:230/255 alpha:1.00];
}
+ (UIColor *)mianTitleColor{
    return [UIColor colorWithHexString:@"#4C4D4D"];
}
+ (UIColor *)contentColor{
    return [UIColor colorWithHexString:@"#888D8C"];
}

+ (CGFloat)colorComponentFrom:(NSString *)string start:(NSUInteger)start length:(NSUInteger)length
{
    
    NSString *substring = [string substringWithRange: NSMakeRange(start, length)];
    
    NSString *fullHex = length == 2 ? substring : [NSString stringWithFormat: @"%@%@", substring, substring];
    
    unsigned hexComponent;
    
    [[NSScanner scannerWithString: fullHex] scanHexInt: &hexComponent];
    
    return hexComponent/255.0;
    
}



+ (UIColor *)colorWithHexString:(NSString *)hexString
{
    
    NSString *colorString = [[hexString stringByReplacingOccurrencesOfString: @"#"withString: @""] uppercaseString];
    CGFloat alpha, red, blue, green;
    
    switch ([colorString length]) {
        case 3: // #RGB
            alpha = 1.0f;
            red   = [self colorComponentFrom: colorString start: 0 length: 1];
            green = [self colorComponentFrom: colorString start: 1 length: 1];
            blue  = [self colorComponentFrom: colorString start: 2 length: 1];
            break;
        case 4: // #ARGB
            alpha = [self colorComponentFrom: colorString start: 0 length: 1];
            red   = [self colorComponentFrom: colorString start: 1 length: 1];
            green = [self colorComponentFrom: colorString start: 2 length: 1];
            blue  = [self colorComponentFrom: colorString start: 3 length: 1];
            break;
        case 6: // #RRGGBB
            alpha = 1.0f;
            red   = [self colorComponentFrom: colorString start: 0 length: 2];
            green = [self colorComponentFrom: colorString start: 2 length: 2];
            blue  = [self colorComponentFrom: colorString start: 4 length: 2];
            break;
        case 8: // #AARRGGBB
            alpha = [self colorComponentFrom: colorString start: 0 length: 2];
            red   = [self colorComponentFrom: colorString start: 2 length: 2];
            green = [self colorComponentFrom: colorString start: 4 length: 2];
            blue  = [self colorComponentFrom: colorString start: 6 length: 2];
            break;
        default:
            @throw [[NSException alloc] initWithName:@"Invalid color value" reason:[NSString stringWithFormat:@"Color value \"%@\" is invalid.  It should be a hex value of the form #RBG, #ARGB, #RRGGBB, or #AARRGGBB.", hexString] userInfo:nil];
            break;
    }
    
    return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
    
}

@end
